<script setup lang="ts">
import { authMenuHandle, getMenuHandleData, saveHandleKey } from '@/util/menu'
import { onMounted } from 'vue'

/**
 * authTag :权限标识
 * disabled : 禁用状态
 * authShow : 在无权限的时候的显示状态
 */
const props = defineProps<{
  authTag?: string
  disabled?: boolean
  authShow?: boolean
}>()
onMounted(() => {
  if (props.authTag) {
    saveHandleKey(props.authTag)
  }
})
/* 初始化按钮信息 */
const buttonInfo = getMenuHandleData(props.authTag || '')
</script>
<template>
  <el-switch
    v-if="buttonInfo.show == '1' && (authMenuHandle(buttonInfo.tag!) || authShow)"
    :disabled="disabled || buttonInfo.status != '1' || !authMenuHandle(buttonInfo.tag!)"
    active-value="1"
    inactive-value="0"
    style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
  />
</template>
